package thread;

/**
 * sleep面试题:
 * 当调用Tread.sleep(1000).实际情况祖肃时间是:大于1秒钟的
 *
 *
 *
 *
 *
 * sleep方法要求必须处理中断异常
 * 当一个线程调用sleep方法处于睡眠阻塞的过程中,该线程的interrupt方法
 * 被调用时,此时会打断
 */
public class SleepDemo02 {
    public static void main(String[] args) {
        Thread lin = new Thread(){
            @Override
            public void run() {
                System.out.println("林:累了,睡一会");
                try {
                    Thread.sleep(100000000);
                } catch (InterruptedException e) {
                    System.out.println("干啥呢!干啥呢!干啥呢!");
                }
                System.out.println("林:醒了");
            }
        };
        Thread huang = new Thread(){
            @Override
            public void run() {
                System.out.println("大团80 小团40");
                for (int i = 0; i < 5; i++) {
                    System.out.println(80);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
                System.out.println("大哥,搞定");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                lin.interrupt();//中断lin线程的睡眠中断
            }
        };
        lin.start();
        huang.start();

    }
}
